﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class control_vemaybay_VeMayBayNoiDia : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

        }
    }
    protected string GetInfoTitleLoaiVe()
    {
        string htmlCode = "";
        long idMenu = Convert.ToInt64(Request.QueryString.Get("menu"));
        string tileTour = "";
        DataTable tenmenu = DataAccess.ExeSQLToDataTable("select name_menu from dev_menu where  idmenu = '" + idMenu + "'");
        if (tenmenu.Rows.Count > 0)
        {
            tileTour = tenmenu.Rows[0][0].ToString();
            htmlCode +=
                "<img src='style/css/img/icon-dulich-trongnuoc.png' /><a>" + tileTour + @" - Du lịch Lanh Đại</a>";
        }
        return htmlCode;

    }
    protected string GetListInfoLoaiVe()
    {
        string htmlCode = "";
        string check = "?menu=161&parent=0?id=0";
        long idMenu = Convert.ToInt64(Request.QueryString.Get("menu"));
        long idParent = Convert.ToInt64(Request.QueryString.Get("parent"));
        string link_web = "?menu=" + (idMenu == 0 ? 169 : idMenu) + "&parent=" + (idParent == 0 ? 163 : idParent) + "";
        DataTable tbl = DataAccess.ExeSQLToDataTable("select * from dev_news where vemaybay=1 and status = 1 and link_web = '" + link_web + "' order by idnews desc");
        foreach (DataRow dr in tbl.Rows)
        {
            htmlCode +=
                @"<div class='div_content_center_tour_khung'>
                    <input type='hidden' id='totalrow' value='" + tbl.Rows.Count + @"'>
                    <div class='img-daidien_tour'>
                        <img src='files_upload/images/pictour/" + dr["picture"] + @"' />
                    </div>
                    <div class='noidung_tour_short'>
                       <div class='name_tour'>
                            <a href='chitietvemaybay.aspx?id=" + dr["idnews"] + @"'><b>" + ITNLip.CatChuoi(dr["title"].ToString(), 80) + @"</b></a>
                        </div>
                        <div class='list_info_tour'>
                            <ul>
                                <li>
                                    <b>Xuất phát: </b><a>" + GetNameDiaDiemById(dr["diemxuatphat"] == null ? 0 : Convert.ToInt64(dr["diemxuatphat"])) + @"</a>
                                </li>
                                <li>
                                    <b>Điểm đến: </b><a>" + GetNameDiaDiemById(dr["diemden"] == null ? 0 : Convert.ToInt64(dr["diemden"])) + @"</a>
                                </li>
                                <li>
                                    <b>Hãng bay: </b><a>" + (GetNameHangBayById(Convert.ToInt64(dr["hangbay"]) ==null?0:Convert.ToInt64(dr["hangbay"]))) + @"</a>
                                </li>
                                <li>
                                    <b>Giá vé: </b><a class='giakm'>" + (dr["giatour"] == null || dr["giatour"].ToString() == "" ? "Liên hệ" : (String.Format("{0:0,0}", dr["giatour"])) + "VNĐ") + @"</a>
                                </li>
                                <li>
                                    <b>Giá vé: </b><a>" + dr["khuhoi"] + @"</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class='btn_Xemchitiet'>
                        <div class='style_like_face'>
                            <div class='fb-like' data-href='http://lanhdaitourist.com/chitiettourdulich.aspx?id=" + dr["idnews"] + @"' data-send='true' data-layout='button_count'
                                data-show-faces='true'>
                            </div>
                        </div>
                        <a class='style_btnDattour' href='datvemaybay.aspx?id=" + dr["idnews"] + @"' >Đặt vé</a>
                        <a class='style_btnXemtour' href='chitietvemaybay.aspx?id=" + dr["idnews"] + @"'>Chi tiết</a>
                    </div>
                </div>";
        }
        return htmlCode;
    }

    protected string GetNameDiaDiemById(long id)
    {
        DataTable dt = DataAccess.ExeSQLToDataTable("select Name from DiaDanh where IdYahoo = '" + id + "'");
        if (dt.Rows.Count == 0)
        {
            return "";
        }
        else
        {
            return dt.Rows[0][0] == null ? "" : dt.Rows[0][0].ToString();
        }

    }
    protected string GetNameHangBayById(long id)
    {
        DataTable dt = DataAccess.ExeSQLToDataTable("select Name from HangBay where Id = '" + id + "'");
        if (dt.Rows.Count == 0)
        {
            return "";
        }
        else
        {
            return dt.Rows[0][0] == null ? "" : dt.Rows[0][0].ToString();
        }

    }
}